Ext.define('TS.view.dilema.CounterpointGrid' , {
	extend: 'TS.lib.Grid',
	alias : 'widget.dilemapointcounterpointgrid',
	tbar:[
		Factory.btn.ico('search',Factory.toolbar._.go,{
			fix:'dilemapointcounterpointgrid',
			flds:{
				hidden:['argument']
			}
		}),
		
		{xtype:'hidden',name:'argument',names:['dilema_point_counterpoint.dilema_point_id','counterpoint_id'],getVal:function(){
			return Util.fldVal('dilema_point->id');
		}},
		
		Factory.btn.ico('add',
			function(){
				var fix = 'dilemapointcounterpoint';
				Factory.winForm(fix,null,'simple');
				/*
				if(!Util.form(fix)){
					Ext.create('TS.lib.Window',{
						layout:'anchor',width:400,
						items:[{xtype:fix+'form'}]
					});
				} else {
					Util.f.clear(fix);
				}*/
				
				Util.fldVal(fix+'->#dilema_point_id','dilema_point->id');
				Util.s.load(Util.fld(fix+'->#counterpoint_id').getStore(),where(
					['dilema_id',Util.fldVal('dilema->id')],
					['dilema_point_side',Util.fldVal('dilema_point->side')=='1'?'0':'1']
				));
			}
		)
	
	],
	frame:false,
	store: 'DilemaPointCounterpoint',
	listeners:{
		'itemdblclick':function(){
			
		}
	},
	columns: [
	 	{xtype: 'rownumberer'},{
			header:'ID',
			hidden:true,
			dataIndex:'dilema_point_counterpoint_id'
		},{
			header:'Kontrtargument',
			sortable:true,
			dataIndex:'dilema_point_counterpoint_id',
			renderer:function(v,index,rec){
				var test = rec.data.counter_side != Util.fldVal('dilema_point->side');//counter ma inny side niż Ten 
				var id = test ? rec.data.counterpoint_id : rec.data.dilema_point_id;
				var side = (test ?'counter' : 'point');
				
				return '<div style="color:red;font-weight:bold;">'+rec.data[side+'_head']+'</div>' +
						'<div style="color:gray;font-size:9px;padding:5px;white-space:normal">'+rec.data[side+'_body']+'</div>';
			}
		},{
			header:'Argument',
			hidden:true,
			dataIndex:'dilema_point_id'
		},{
			header:'Kontrargument',
			hidden:true,
			dataIndex:'counterpoint_id'
		}
	]
});